package cac.fenjian.resource.BZJReceive.service;

import cac.fenjian.resource.BZJReceive.dao.BZJReceiveDao;
import com.cac.dme.adapter.rest.msg.QueryReqBean;
import com.cac.dme.adapter.rest.msg.QueryRespBean;
import com.cac.dme.adapter.utils.PageHelper;
import com.cac.dme.common.exception.service.DaoException;
import com.github.pagehelper.Page;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;

/**
 * @className: BZJReceiveService
 * @description: （描述这个类的作用）
 * @author: lqc
 * @date: 2023/5/26 10:04:04 周五
 * @version: 1.0
 */
@Service
@Slf4j
public class BZJReceiveService {

    @Autowired
    private BZJReceiveDao bzjReceiveDao;

    //待接收标准件查询，条件查询
    public QueryRespBean<HashMap> searchBZJCode(QueryReqBean<HashMap> queryReqBean,String barcode,String bzjCodeType,String shop) {
        QueryRespBean<HashMap> queryRespBean = new QueryRespBean<>();
        try {
            PageHelper.startPage(queryReqBean.getPageParameter());
            HashMap searchParams = queryReqBean.getSearchParams();
            if(searchParams==null){
                searchParams = new HashMap();
                searchParams.put("requireShop",shop);
            }else{
                searchParams.put("requireShop",shop);
            }
            Page<HashMap> dataList = bzjReceiveDao.searchBZJCode(searchParams,barcode,bzjCodeType);
            queryRespBean.setResult(dataList);
            return queryRespBean;
        } catch (Exception e) {
            e.printStackTrace();
            throw new DaoException(e.getMessage(), e);
        }
    }
    //更改交接单
    public void changeTransferType4Bzj(String wmsDeliveryPlanId,String receiveEmpCode,String ip){
        //更新交接单数据
        bzjReceiveDao.changeTransferType4Bzj(wmsDeliveryPlanId,receiveEmpCode,ip);
    }
}
